'use strict';

exports.__esModule = true;
exports.injectReducer = exports.createReducer = undefined;

var _has = require('babel-runtime/core-js/reflect/has');

var _has2 = _interopRequireDefault(_has);

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _redux = require('redux');

var _reactRouterRedux = require('react-router-redux');

var _system = require('./modules/system');

var _system2 = _interopRequireDefault(_system);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function createReducer(asyncReducers) {
  return (0, _redux.combineReducers)((0, _extends3.default)({}, asyncReducers, {
    system: _system2.default,
    router: _reactRouterRedux.routerReducer
  }));
}

function injectReducer(store, _ref) {
  var key = _ref.key,
      reducer = _ref.reducer;

  if ((0, _has2.default)(store.asyncReducers, key)) return;

  store.asyncReducers[key] = reducer; // eslint-disable-line no-param-reassign
  store.replaceReducer(createReducer(store.asyncReducers));
}

exports.createReducer = createReducer;
exports.injectReducer = injectReducer;